package com.yucc.girlimages.io;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.yucc.girlimages.io.model.GirlInfo;

import android.content.Context;

public class GirlInfoHandler extends JSONHandler {

	public GirlInfoHandler(Context context) {
		super(context);
	}

	@Override
	public List<GirlInfo> parse(String json) throws IOException {
		// TODO Auto-generated method stub

		JsonParser parser = new JsonParser();
		JsonObject object = parser.parse(json).getAsJsonObject();

		JsonArray array = object.get("list").getAsJsonArray();
		int totalCount = object.get("totalCount").getAsInt();
		Type collectionType = new TypeToken<List<GirlInfo>>() {
		}.getType();
		List<GirlInfo> list = new Gson().fromJson(array, collectionType);
		return list;
	}

}
